package com.watson.activity;

import android.app.Dialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Base64;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.watson.BaseActivity;
import com.watson.R;
import com.watson.http.CommonHttpConsts;
import com.watson.http.HttpCallbackWdss;
import com.watson.http.HttpClient;
import com.watson.utils.DialogUitl;
import com.watson.utils.LogUtils;
import com.watson.utils.SPUtils;
import com.watson.utils.StringUtils;
import com.watson.utils.ToastUtil;

import org.json.JSONObject;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class PointActivity extends BaseActivity {
    private TextView tvTitle, tvName, tvNum, tvXue, tvType, tvDu, tvTu;
    private ImageView imgPai;
    private LinearLayout lyLayout;
    private final int REQUEST_IMAGE_CAPTURE = 1001;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_point);
        statusbar4();

        tvTitle = findViewById(R.id.tvTitle);
        lyLayout = findViewById(R.id.lyLayout);
        lyLayout.setVisibility(View.GONE);
        tvTitle.setText(getIntent().getStringExtra("title") + "");
        tvName = findViewById(R.id.tvName);
        tvNum = findViewById(R.id.tvNum);
        tvXue = findViewById(R.id.tvXue);
        tvType = findViewById(R.id.tvType);
        tvDu = findViewById(R.id.tvDu);
        tvTu = findViewById(R.id.tvTu);

        findViewById(R.id.imgBack).setOnClickListener(v -> finish());
        imgPai = findViewById(R.id.imgPai);
        findViewById(R.id.pai_btn).setOnClickListener(v -> {

        });
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            if (requestCode == REQUEST_IMAGE_CAPTURE) {
                Bundle extras = data.getExtras();
                Bitmap imageBitmap = (Bitmap) extras.get("data");
                // 在这里处理你的Bitmap，比如显示在ImageView中或保存到文件系统
                if (imageBitmap != null) {
                    lyLayout.setVisibility(View.VISIBLE);
                    imgPai.setImageBitmap(imageBitmap);
                    // 创建Random对象
                }
            }
        }
    }

    private void setView(Map data) {
        tvName.setText(data.get("RegName") + "");
        tvNum.setText(data.get("Similarity") + "");
        tvXue.setText(data.get("LatinName") + "");
        tvType.setText(data.get("RegType") + "");
        tvDu.setText(data.get("Toxicity") + "");
//        switch (i) {
//            case 0:
//                tvName.setText("升麻");
//                tvNum.setText("45%");
//                tvXue.setText("Cimicifuga foetida L.");
//                tvType.setText("药材");
//                tvDu.setText("毒性药材");
//                break;
//            case 1:
//                tvName.setText("百部");
//                tvNum.setText("56%");
//                tvXue.setText("Stemona sessilifolia （Miq.）Miq.");
//                tvType.setText("药材");
//                tvDu.setText("毒性药材");
//                break;
//            case 2:
//                tvName.setText("川楝子");
//                tvNum.setText("43%");
//                tvXue.setText("Melia toosendan Sieb. et Zucc.");
//                tvType.setText("药材");
//                tvDu.setText("毒性药材");
//                break;
//        }
    }
}
